<?php
/**
	Formul�rio para cadastro de um programa.
*/

if(!isset($_SESSION))
{
   session_start();
}

if( !function_exists('__autoload') )
{
    function __autoload($class_name) {
    require_once $class_name . '.php';
    }
}

$ano = new Ano();
$anosCadastrados = $ano->CarregarAnos();

SAEO::ValidarAcesso( array( 0, 2 ) )

?>
<html>
	<head>
		<title>SAEO - Cadastro de Fonte</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link rel='stylesheet' type='text/css' href='templates/estilos.css'>
		<script type='text/javascript' src='templates/hintbox.js'></script>
		<script type='text/javascript' src='templates/ajax.js'></script>
		<script type='text/javascript' src='templates/validacoes.js'></script>
		<script type='text/javascript' src='templates/fonte.js'></script>
		<script type='text/javascript' src='templates/programa.js'></script>
	</head>
	<body class='body' onload='javascript: CarregarProgramas(document.cadastrar_fonte.anoId.value ); document.cadastrar_fonte.fonteRecurso.focus();'>
		<form name='cadastrar_fonte' action='EnviarDadosFonte.php?operacao=1' method='post' onsubmit='return ValidarCadastroFonte();'>
		<table width='779' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#FFFFFF'>
			<tr>
				<td colspan='2'><?php include "Topo.php"; ?></td>
			</tr>
			<tr>
				<td>
					<div class='titulosTabelas' style='width:779; height:20; background:url(templates/tabela.jpg)'>CADASTRO DE FONTE</div>
				</td>
            </tr>
            <tr>
                <td colspan='2'>&nbsp;</td>
            </tr>
            <tr>
                <td>
                	<table class='tabela' width='650' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#FFFFFF'>
						<tr>
							<td>&nbsp;</td>
						</tr>
						<tr>
							<td class='textoTabelas'>&nbsp;Ano:</td>
							<td>
								<select name='anoId' id="anoId" class='inputTexto' style="width: 88px;" onchange='CarregarProgramas( this.value );'>                             
                               			<?php
                               			$anoAtual = $ano->getAnoAtual(); 
			                            // Percorre o array anosCadastrados e cria options para cada posi��o.
			                            for ($i = 0; $i < count( $anosCadastrados ); $i++){
			                            	$status = $anoAtual == $anosCadastrados[$i]->ano ? "selected" : "";
			                            	echo "<option value='".$anosCadastrados[$i]->id."' $status>".$anosCadastrados[$i]->ano."</option>";
			                            }
										?>
                               </select> 
								<a href='#' class='hintanchor' onMouseover='showhint("Ano da ação cadastrado no sistema.", this, event, "220px");'>[?]</a>
							</td>
						</tr>
						<tr>
							<td>&nbsp;</td>
						</tr>
						<tr>
							<td width="30%" class='textoTabelas'>&nbsp;A&ccedil;&atilde;o Or&ccedil;ament&aacute;ria:</td>
							<td>
								<select name='programaId' id="listaProgramas" class='inputTexto' style="width: 300px;">                             
                               			<option value="0" id="programa">Selecione Primeiro o Ano...</option>
                               </select> 
								<a href='#' class='hintanchor' onMouseover='showhint("Lista de Programas cadastrados no sistema.", this, event, "220px");'>[?]</a>
							</td>
						
						<tr>
							<td colspan='2'>&nbsp;</td>
						</tr>
						<tr>
							<td class='textoTabelas'>&nbsp;Tipo de despesa:</td>
							<td>
								<select name='tipoDespesa' id="tipoDespesa" class='inputTexto' ">                             
                               			<option value="33" id="despesa">33 - Corrente</option>
                               			<option value="44" id="despesa">44 - Capital</option>
                               </select> 
								<a href='#' class='hintanchor' onMouseover='showhint("Tipo de Despesa da Fonte.", this, event, "220px");'>[?]</a>
							</td>
						</tr>
						<tr>
							<td colspan='2'>&nbsp;</td>
						</tr>						
						<tr>
							<td class='textoTabelas'>&nbsp;Fonte de Recurso:</td>
							<td>
								<input class="inputNumeros" name="fonteRecurso" id="fonteRecurso" type="text" size="15" maxlength="10" onkeypress="return soNumero(event)" />
								<a href='#' class='hintanchor' onMouseover='showhint("C&oacute;digo da Fonte de Recurso.", this, event, "220px");'>[?]</a>
							</td>
						</tr>
						<tr>
							<td colspan='2'>&nbsp;</td>
						</tr>						
						<tr>
 							<td class="textoTabelas">&nbsp;Valor:</td>
    						<td><input class="inputNumeros" name="valorFonte" id="valorFonte"type="text" size="15" maxlength="13" onKeyPress="reais(this,event);" onKeyDown="backspace(this,event);" />
								<a href='#' class='hintanchor' onMouseover='showhint("Valor da Fonte de Recurso.", this, event, "220px");'>[?]</a>
							</td>
						</tr>						
						<tr>
							<td colspan='2'>&nbsp;</td>
						</tr>
						<tr>
							<td colspan='2' height='46'>
								<div style='position:relative;left:540px'>
									<input type='image' style='width:100px;height:30px;' onclick='EnviarInformacoes();' src='templates/btavancar.JPG'/>
								</div>
							</td>
						</tr>
                     </table>
                </td>
			</tr>
            <tr>
                <td>&nbsp;</td>
            </tr>
            <tfoot>
	           	<tr>
					<td colspan='2'>&nbsp;</td>
	            </tr>
				<tr>
                   	<?php include 'rodapeCreditos.php'; ?>
                   </tr>
            </tfoot>
		</table>
     	</form>
	</body>
</html>